package com.gr.experimental.utils.validation;

public class ValidationUtils {

	public static void assertObjectNotNull(String description, Object object) throws ValidationException {
		if (object == null) {
			throw new ValidationException(description + " is null." );
		}
	}
	
	public static void assertObjectClass(String description, Object object, Class<?> objectClass) throws ValidationException {
		if (!objectClass.isAssignableFrom(object.getClass())) {
			throw new ValidationException(description + " not an instance of " + objectClass);
		}
	}

	public static void assertClassAssignable(String description, Class<?> targetClass, Class<?> assignedClass) throws ValidationException {
		if (!targetClass.isAssignableFrom(assignedClass)) {
			throw new ValidationException(description + ":" + targetClass + " not assignable from " + assignedClass);
		}
	}

}
